package org.yohailong.studyreactfrombilibili.genreate;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

/**
 * @author 朱海龙
 * 2025/9/7 11:58
 */
public class GenerateDao {

    public static final String url      = "jdbc:mysql://localhost:3307/study_react_from_bilibili";
    public static final String username = "root";
    public static final String password = "Castlong68949233";

    public static void main(String[] args) {
        FastAutoGenerator.create(url, username, password)
                         .globalConfig(builder -> builder.author("YoHaiLong")
                                                         .outputDir("D:\\code\\java-study\\study-react-from-bilibili\\study-react-from-bilibili\\src\\test\\java")
                                                         .commentDate("yyyy-MM-dd"))
                         .packageConfig(builder -> builder.parent("org.yohailong.studyreactfrombilibili")
                                                          .entity("dao.entity")
                                                          .mapper("dao.mapper")
                                                          .service("dao")
                                                          .serviceImpl("dao.impl")
                                                          .xml("dao.mapper.xml"))
                         .strategyConfig(builder -> builder.entityBuilder()
                                                           .formatFileName("%sEntity")
                                                           .enableLombok()
                                                           .serviceBuilder()
                                                           .formatServiceFileName("%sDao")
                                                           .serviceBuilder()
                                                           .formatServiceImplFileName("%sDaoImpl")
                                                           .controllerBuilder()
                                                           .disable())
                         .strategyConfig(builder -> builder.addInclude("comment")
                                                           .addInclude("user")// 设置需要生成的表名
                         )
                         .templateEngine(new FreemarkerTemplateEngine())
                         .execute();
    }
}
